﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OneSoft.EntityCore;
using OneSoft.DataAccess;
using System.Data;

using BySoft.Server.Consts;
using BySoft.Server.Common.Entity;
using BySoft.Server.Common.Schema;
using BySoft.Server.DataAccess;
namespace BySoft.Server.Business
{
    public class Common
    {
        public static DataTable ReturnDataTable(string sql)
        { 
            try
            {
                return BySoft.Server.Business.Common.ReturnDataTable(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        #region ExecuteDataTable
        /// <summary>
        ///  执行SQL，返回指定数量的记录
        /// </summary>
        /// <param name="strSql">SQL语句</param>
        /// <param name="maxCount">查询的数量</param>
        /// <returns>结果集</returns>
        public static DataTable ExecuteDataTable(string strSql,int maxCount)
        {
            int count=0;
            DataTable dt=DataAccessCommon.ExecuteDataTablePaging(strSql, 0, maxCount, out count);
            if (dt != null && dt.Columns.Count >= 2)
            {
                if (dt.Columns[0].ColumnName.ToUpper() == "NUM")
                {
                    dt.Columns.Remove(dt.Columns[0]);//去掉rowNum 列;
                }
            }
            return dt;
        }



        /// <summary>
        ///  执行SQL，返回指定数量的记录
        /// </summary>
        /// <param name="strSql">SQL语句</param>
        /// <param name="maxCount">查询的数量</param>
        /// <returns>结果集</returns>
        public static DataTable ExecuteDataTableFor2000(string strSql, int maxCount, String Order)
        {
            int count = 0;
            DataAccessParameterCollection dpc = new DataAccessParameterCollection();
            DataTable dt = DataAccessCommon.ExecuteDataTablePagingFor2000(strSql, 0, maxCount,dpc, out count,Order);
            if (dt != null && dt.Columns.Count >= 2)
            {
                if (dt.Columns[0].ColumnName.ToUpper() == "NUM")
                {
                    dt.Columns.Remove(dt.Columns[0]);//去掉rowNum 列;
                }
            }
            return dt;
        }
        #endregion

    }
}
